import { Log } from "../debug/Log";
import { KeyBoardManager } from "../keyBoard/KeyBoardManager";
import { Alert } from "../../mui/controls/Alert";
type int = number;
//class TimerTest
    
    export  class TimerTest /* flash.display.Sprite */
    {
        constructor(arg1: Object /* flash.display.Stage */)
        {
            this._frame = arg1.frameRate;
            this._stage = arg1;
            return;
        }

        public start(): void
        {
            this._sTime = flash.utils.getTimer();
            this._dsTime = new Date().time;
            this._stage.addEventListener(flash.events.Event.ENTER_FRAME, this.onEventFrameHandler);
            return;
        }

        /* internal  */onEventFrameHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1;
            var loc2=((loc1 = this).i + 1);
            loc1.i = loc2;
            if (this.i > 5) 
            {
                this.i = 1;
                this.testChangeTime();
            }
            return;
        }

        /* internal  */testChangeTime(): void
        {
            var loc1=flash.utils.getTimer();
            var loc2=new Date().time;
            var loc3=loc1 - this._sTime;
            var loc4=loc2 - this._dsTime;
            var loc5=Math.abs(loc3 - loc4);
            Log.debug("delayTime:" + loc5 + "==" + [loc3, loc4]);
            if (loc5 > TimerTest.Delay && loc5 < this.MaxDelay) 
            {
                var loc6;
                var loc7=((loc6 = this)._num + 1);
                loc6._num = loc7;
                if (this._num > 5) 
                {
                    if (this._isAlert == false) 
                    {
                        KeyBoardManager.instance.cancelListener();
                        this._isAlert = true;
                        Alert.show(TimerTest.tipText, null, 0, null, this.close);
                    }
                }
            }
            this._sTime = loc1;
            this._dsTime = loc2;
            return;
        }

        /* internal  */close(arg1: int): void
        {
            this._isAlert = false;
            flash.net.navigateToURL(new Object /* flash.net.URLRequest */("javascript: location.reload();"), "_self");
            this._stage.removeEventListener(flash.events.Event.ENTER_FRAME, this.onEventFrameHandler);
            return;
        }

        private /* var */_sTime: number;

        private /* var */_dsTime: number;

        private /* var */_frame: int=12;

        private /* var */MaxDelay: number=10000;

        private /* var */_stage: Object /* flash.display.Stage */;

        private /* var */_num: int=0;

        private /* var */_isAlert: Boolean=false;

        private /* var */i: int=1;

        public static /* var */Delay: number=40;

        public static /* var */tipText: string="检测到当前系统时间被修改，若是手动修改，\n请刷新后再进行游戏";
    }

            TimerTest.Delay = 40;
            TimerTest.tipText = "检测到当前系统时间被修改，若是手动修改，\n请刷新后再进行游戏";
        